//
//  StaticObj.cpp
//  NinjaTurtle
//
//  Created by Nguyen Tri Chung on 2/6/15.
//
//

#include "StaticObj.h"

StaticObj::StaticObj(const string& identifier) {
    CSprite* mainFace = new CSprite(SPRITE_TYPE_MAIN);
    mainFace->initWithIdentifier(identifier);
    this->sprites->pushBack(mainFace);
    
    RectBody* body = new RectBody(mainFace->getContentSize().width, mainFace->getContentSize().height);
    CC_SAFE_RETAIN(body);
    this->body = body;
    
    this->initStaticObj();
}

StaticObj::StaticObj(const string& identifier, const string& animation) {
    CSprite* mainFace = new CSprite(SPRITE_TYPE_MAIN);
    mainFace->initWithIdentifier(identifier);
    mainFace->bind(CStringUtil::getPattern(animation));
    this->sprites->pushBack(mainFace);
    
    RectBody* body = new RectBody(mainFace->getContentSize().width, mainFace->getContentSize().height);
    CC_SAFE_RETAIN(body);
    this->body = body;
    
    this->initStaticObj();
}

StaticObj::StaticObj(const string& identifier, const vector<string>& animations) {
    CSprite* mainFace = new CSprite(SPRITE_TYPE_MAIN);
    mainFace->initWithIdentifier(identifier);
    for (auto animation = animations.begin(); animation < animations.end(); animation++) {
        string animationIdentifier = *animation;
        mainFace->bind(CStringUtil::getPattern(animationIdentifier));
    }
    this->sprites->pushBack(mainFace);
    
    RectBody* body = new RectBody(mainFace->getContentSize().width, mainFace->getContentSize().height);
    CC_SAFE_RETAIN(body);
    this->body = body;
    
    this->initStaticObj();
}

void StaticObj::initStaticObj() {
    this->currentElapsedJumpTime = 0;
    this->lastStepY = -9999;
    this->jumping = false;
    this->falling = false;
    this->blocking = false;
    this->objectName = "";
    
    this->currentDelayToBreak = 0;
    
    this->teleportAddress = "";
    this->teleportDestination = "";
}

StaticObj::~StaticObj() {
    
}

void StaticObj::update(float dt) {
    Obj::update(dt);
}